﻿using System;
using System.Collections.Generic;
using System.Linq;
using SLNGP.Core.Individuals;

namespace SLNGP.Core.Run
{
    public class GeneticProgrammingRunResults : IGeneticProgrammingRunResults
    {
        public GeneticProgrammingRunResults()
        {
            Generations = new List<IGeneration>();
        }

        public List<IGeneration> Generations { get; private set; }
        public IGeneration CurrentGeneration
        {
            get
            {
                if (Generations.Count < 2)
                    throw new GeneticProgrammingException("Invalid state for GeneticProgrammingRunResults.");

                return Generations[Generations.Count - 1];
            }
        }
        public IGeneration LastGeneration
        {
            get
            {
                if (Generations.Count < 2)
                    throw new GeneticProgrammingException("Invalid state for GeneticProgrammingRunResults.");

                return Generations[Generations.Count - 2];
            }
        }
    }
}